﻿<Controls:SinacorWindow
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Validation="clr-namespace:Sinacor.Infra.UI.Controls.SmartClient.Validation;assembly=Sinacor.Infra.UI.Controls"
    xmlns:Local="clr-namespace:Sinacor.UI.Bovespa.Ordens.View.SmartClient"
	x:Class="Sinacor.UI.Bovespa.Ordens.View.SmartClient.DistribuicaoOrdemDigitacao"
     xmlns:System="clr-namespace:System;assembly=mscorlib"
	Title="{DynamicResource Bovespa.Ordens.Label.DistribuicaoOrdemDigitacao}"
	xmlns:Controls="clr-namespace:Sinacor.Infra.UI.Controls.SmartClient;assembly=Sinacor.Infra.UI.Controls"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    ModuleId = "ORD"  
    ModulePlus="false"
    WindowStartupLocation="CenterScreen"
    WindowState ="Maximized"   AutoContentHeight="False" AutoContentWidth="True"               >

    <Controls:SinacorWindow.Resources>
        <Grid VerticalAlignment="Top" HorizontalAlignment="Left" x:Key="ClientesPopUpTemplate"   Margin="0,4,0,0"  >
            <Controls:SinacorListBox ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible"
           x:Name="listBoxClientes"
           Margin="2,4,0,0"
           Width="400"  Height="100"
           HorizontalAlignment="Left"
           VerticalAlignment="Top"
           ItemsSource="{Binding ListModelClienteCVM}"
           MouseDoubleClick="listBoxClientes_MouseDoubleClick"   >
                <Controls:SinacorListBox.ItemTemplate>
                    <DataTemplate>
                        <StackPanel Orientation="Horizontal">
                            <Controls:SinacorTextBlock Text="{Binding Apelido}" />
                            <Controls:SinacorTextBlock Text="{Binding Codigo}"/>
                            <Controls:SinacorTextBlock Text="{Binding Nome}"/>
                        </StackPanel>
                    </DataTemplate>
                </Controls:SinacorListBox.ItemTemplate>
            </Controls:SinacorListBox>
        </Grid>
    </Controls:SinacorWindow.Resources>
    <Controls:SinacorExpanderContainer x:Name="DistribuicaoOrdemDigitacao1">
        <Controls:SinacorExpanderContainer.RowDefinitions>

            <RowDefinition Height="240"  />
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto" />

        </Controls:SinacorExpanderContainer.RowDefinitions>

        <Controls:SinacorExpander Header="{DynamicResource Bovespa.Ordens.Label.OrdensNegocio}"  
                                          Grid.Row="0" Grid.Column="0"
                                          Margin="0,0,4,0" x:Name="exp0" IsExpanded="True">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="65*" MinWidth="100"></ColumnDefinition>
                    <ColumnDefinition Width="2"></ColumnDefinition>
                    <ColumnDefinition Width="35*" MinWidth="100"></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Controls:SinacorDataGrid Grid.Column="0"  x:Name="dtgOrdens" ItemsSource="{Binding Path=ListOrdem}" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                    <Controls:SinacorDataGrid.Columns>
                        <Controls:Column Name="Ativo" DisplayMemberPath="Titulo"	Title="Bovespa.Ordens.Label.Ativo"	AllowInsert="False"  />
                        <Controls:Column Name="NomeCliente" DisplayMemberPath="ApelidoCliente" Title="Bovespa.Ordens.Label.NomeCliente" AllowInsert="False"/>
                        <Controls:Column Name="DataOrdem" DisplayMemberPath="DataOrdem" Title="Bovespa.Ordens.Label.DataOrdem" AllowInsert="False" HorizontalCellAlignment="Center" />
                        <Controls:Column Name="Mercado" DisplayMemberPath="TipoMercado" Title="Bovespa.Ordens.Label.Mercado" AllowInsert="False"/>
                        <Controls:Column Name="NaturezaOperacao" DisplayMemberPath="NaturezaOperacao" Title="Bovespa.Ordens.Label.NaturezaOperacao" AllowInsert="False"/>
                        <Controls:Column Name="NumeroLote" DisplayMemberPath="NumeroConjunto" Title="Bovespa.Ordens.Label.NumeroLote" AllowInsert="False" HorizontalCellAlignment="Right"/>
                        <Controls:Column Name="NumeroOrdem" DisplayMemberPath="NumeroOrdem" Title="Bovespa.Ordens.Label.NumeroOrdem" AllowInsert="False"  HorizontalCellAlignment="Right" />
                        <Controls:Column Name="Operador" DisplayMemberPath="LoginOperador" Title="Bovespa.Ordens.Label.Operador" AllowInsert="False" />
                        <Controls:Column Name="Quantidade" DisplayMemberPath="Quantidade" Title="Bovespa.Ordens.Label.Quantidade" AllowInsert="False" HorizontalCellAlignment="Right" StringFormat="n4" />
                        <Controls:Column Name="Subsequencia" DisplayMemberPath="NumeroOrdemSequencia" Title="Bovespa.Ordens.Label.Subsequencia" AllowInsert="False" HorizontalCellAlignment="Right" />
                    </Controls:SinacorDataGrid.Columns>
                </Controls:SinacorDataGrid>

                <Grid Grid.Column="2" Margin="4,0,0,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="*"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Controls:SinacorDataGrid Grid.Row="0"  x:Name="dtgNegocio" ItemsSource="{Binding Path=ListNegocio}"
                            Margin="0,0,4,0" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                        <Controls:SinacorDataGrid.Columns>
                            <Controls:Column Name="Preco" DisplayMemberPath="Preco" Title="Bovespa.Ordens.Label.Preco" AllowInsert="False" StringFormat="n8" Integers="20" Decimals="8" HorizontalCellAlignment="Right" />
                            <Controls:Column Name="Quantidade" DisplayMemberPath="Quantidade" Title="Bovespa.Ordens.Label.Quantidade" AllowInsert="False" Integers="17" Decimals="4" StringFormat="n4" HorizontalCellAlignment="Right" />
                            <Controls:Column Name="QuantidadeEspecificar" DisplayMemberPath="QuantidadeCasada" Title="Bovespa.Ordens.Label.QuantidadeEspecificar" AllowInsert="False" Integers="17" Decimals="4" StringFormat="n4" HorizontalCellAlignment="Right"/>
                        </Controls:SinacorDataGrid.Columns>
                    </Controls:SinacorDataGrid>
                    <StackPanel Grid.Row="1" Orientation="Horizontal" Margin="0,4,0,0" HorizontalAlignment="Right">
                        <Controls:SinacorLabel HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Content="{DynamicResource Bovespa.Ordens.Label.PrecoMedio}" />
                        <Controls:SinacorDecimalTextBox x:Name="PrecoMedio1"  TabIndex="0" Value="{Binding Path=PrecoMedio}" Width="100" HorizontalAlignment="Right" VerticalAlignment="Top" Integers="16" Decimals="6"  IsReadOnly="True" IsFormated="True"  />
                    </StackPanel>
                </Grid>
            </Grid>
        </Controls:SinacorExpander>


        <Controls:SinacorExpander Grid.Row="1" Grid.Column="0" Header="{DynamicResource Bovespa.Ordens.Label.Opcoes}"  x:Name="exp1" Margin="0,4,0,0" IsExpanded="True">
            <Grid  VerticalAlignment="Top" HorizontalAlignment="Stretch">
                <Controls:SinacorCheckBox x:Name="checkBoxUtilizaCodigoCVM" TabIndex="1" Content="{DynamicResource Bovespa.Ordens.Label.UtilizaCodigoCVM}"  Width="150" Margin="0,0,44,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
                <Controls:SinacorCheckBox x:Name="checkBoxContaInvestimento" TabIndex="2" Width="180" Content= "{DynamicResource Bovespa.Ordens.Label.ContaInvestimento}" Margin="154,0,0,0" VerticalAlignment="Top" HorizontalAlignment="Left"/>
            </Grid>
        </Controls:SinacorExpander>
        <Controls:SinacorExpander x:Name="exp2" Grid.Row="2" Grid.Column="0" Header="{DynamicResource Bovespa.Ordens.Label.DistribuicaoPreco}" Margin="0,4,0,0" IsExpanded="True"
                                  >
            <Grid>
                <Controls:SinacorRadioButton x:Name="radioButtomDireto" TabIndex="3" Checked="radioButtomDireto_Checked"    HorizontalAlignment="Left" VerticalAlignment="Top" Content="{DynamicResource Bovespa.Ordens.Label.Direto}" Width="150"/>
                <Controls:SinacorRadioButton x:Name="radioButtomPercentual"  TabIndex="4" Checked="radioButtomPercentual_Checked" HorizontalAlignment="Left" Width="150" Content="{DynamicResource Bovespa.Ordens.Label.Percentual}" Margin="154,0,0,0" VerticalAlignment="Top"/>
                <Controls:SinacorRadioButton x:Name="radioButtomPrecoMedio" TabIndex="5" Checked="radioButtomPrecoMedio_Checked"  HorizontalAlignment="Left" Width="144" Content="{DynamicResource Bovespa.Ordens.Label.PrecoMedio}" Margin="308,0,0,0" VerticalAlignment="Top"/>
                <Controls:SinacorCheckBox x:Name="checkBoxPrecoMedio"  TabIndex="6" Width="180" Content="{DynamicResource Bovespa.Ordens.Label.PrecoMedioVolume}" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="483,0,0,0"/>
                <Controls:SinacorDataGrid IsSynchronizedWithCurrentItem="False" Margin="0,25,0,0" AutoEditOnSelectionChange = "False"
                     ItemsSource="{Binding Path=ListDigitacao}" x:Name="dtgDistribuicao" AllowDelete="True"  
                     SavingAll="dtgDistribuicao_SavingAll" 
                     BeingInserted="dtgDistribuicao_BeingInserted" 
                     SavedAll="dtgDistribuicao_SavedAll"  
                     UpdateBegun="dtgDistribuicao_UpdateBegun" CancelingInsert="dtgDistribuicao_CancelingInsert"  
                     CancelingUpdate="dtgDistribuicao_CancelingUpdate"
                     UndoingAll="dtgDistribuicao_UndoingAll"
                     UpdateEnded="dtgDistribuicao_UpdateEnded"
                     BeingUpdated="dtgDistribuicao_BeingUpdated"
                     Focusable="False"
                     CurrentCellChanged="dtgDistribuicao_CurrentCellChanged"
                     AllowSave="True"  AllowEndUpdate="True" 
                     AllowEndInsert="True" 
                     AllowBeginInsert="True"  AllowBeginUpdate="True"   AllowCancelInsert="True"  AllowCancelUpdate="True"
                     UndidAll="dtgDistribuicao_UndidAll" 
                     Undid="dtgDistribuicao_Undid"
                     InsertEnded="dtgDistribuicao_InsertEnded"  
                     InsertBegun="dtgDistribuicao_InsertBegun" 
                     Deleted="dtgDistribuicao_Deleted" SelectionChanged="dtgDistribuicao_SelectionChanged"
                     KeyboardNavigation.DirectionalNavigation="Once"
                                          >
                    <Controls:SinacorDataGrid.ContextMenuTemplate>
                        <!--I Inserting="dtgDistribuicao_Inserting"  -->
                        <DataTemplate>
                            <StackPanel>
                                <Controls:SinacorContextMenuItem Header="{DynamicResource Bovespa.Ordens.Label.ConsultarClientes}" Click="PesquisaCliente_Click" IsEnabled="{Binding Path=Presenter.DistribuicaoControles.AtivarConsultaCliente, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Controls:SinacorWindow}}}"/>
                            </StackPanel>
                        </DataTemplate>
                    </Controls:SinacorDataGrid.ContextMenuTemplate>
                    <Controls:SinacorDataGrid.Columns>
                        <Controls:Column Name="Cliente" DisplayMemberPath="ApelidoCliente" Width="80"
                                         MaxLength="18" Title="Bovespa.Ordens.Label.ApelidoCliente"
                                         AllowInsert="True"   AllowUpdate="True"
                                        CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorTextBox 
                                        Text="{Binding ApelidoCliente}" 
                                        Name="txtApelidoCliente" 
                                        MaxLength="18" 
                                        GotFocus="txtApelidoCliente_GotFocus" 
                                        IsRequired="True" 
                                        >
                                        <Controls:SinacorTextBox.ValidationRules>
                                            <Validation:EventValidationRule Validating="EventValidationRule_ConsultaClienteCVM_Apelido" />
                                            <Validation:EventValidationRule Validating="EventValidationRule_ValidarCodigoCliente"/>
                                        </Controls:SinacorTextBox.ValidationRules>
                                    </Controls:SinacorTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>
                        <Controls:Column Name="DigitoVerificadorCliente" 
                                          DisplayMemberPath="DigitoVerificadorCliente" 
                                         Title="Bovespa.Ordens.Label.DigitoVerificadorCliente" AllowInsert="True"   AllowUpdate="True"
                                         IsRequired="false" HorizontalCellAlignment="Right" 
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorInt16TextBox Name="txtDigitoVerificador"
                                                                  Value="{Binding DigitoVerificadorCliente }" Integers="1" IsRequired="True" IsFormated="True"  >
                                        <Controls:SinacorInt16TextBox.ValidationRules>
                                            <Validation:EventValidationRule Validating="EventValidationRule_ValidarDigitoCliente"  />
                                        </Controls:SinacorInt16TextBox.ValidationRules>
                                    </Controls:SinacorInt16TextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>
                        <Controls:Column Name="Preco" DisplayMemberPath="PrecoInformado"  
                                         Title="Bovespa.Ordens.Label.Preco" AllowInsert="True"   AllowUpdate="True"
                                         StringFormat="n8"  HorizontalCellAlignment="Right"  
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Name="txtPrecoInformado" 
                                                                    Value="{Binding PrecoInformado }" Integers="20" Decimals="8"  >
                                        <Controls:SinacorDecimalTextBox.ValidationRules>
                                            <Validation:EventValidationRule Validating="EventValidationRule_PrecoInformado" ErrorContent="Bovespa.Ordens.Message.ErroPreco" />
                                            <Validation:EventValidationRule Validating="EventValidationRule_txtPreco" ErrorContent="Bovespa.Ordens.Message.ErroDigitePreco" />
                                        </Controls:SinacorDecimalTextBox.ValidationRules>
                                    </Controls:SinacorDecimalTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>
                        <Controls:Column Name="Quantidade"   DisplayMemberPath="QuantidadeDestinadaCliente"   
                                         Title="Bovespa.Ordens.Label.Quantidade" 
                                         AllowInsert="True"   AllowUpdate="True"
                                         StringFormat="n4"  HorizontalCellAlignment="Right"
                                         
                                         
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Name="txtGridQTDDestinadaCliente"  
                                                                    Value="{Binding QuantidadeDestinadaCliente}"
                                    Integers="17" Decimals="4" Keyboard.PreviewKeyDown="txtGridQTDDestinadaCliente_PreviewKeyDown" IsFormated="True"   >
                                        <Controls:SinacorDecimalTextBox.ValidationRules>
                                            <Validation:EventValidationRule Validating="EventValidationRule_Quantidade" ErrorContent="Bovespa.Ordens.Message.ErroDigiteQuantidade" />
                                            <Validation:EventValidationRule Validating="EventValidationRule_Preco" ErrorContent="Bovespa.Ordens.Message.ErroDigitePreco" />
                                            <Validation:EventValidationRule Validating="EventValidationRule_QuantidadeTotalPreenchida" ErrorContent="Bovespa.Ordens.Message.QuantidadeNegocioMaiorSaldo" />
                                            <Validation:EventValidationRule Validating="EventValidationRule_QTDDestinadaCliente" ErrorContent="Bovespa.Ordens.Message.ErroTotalDigitacao" />
                                            <Validation:EventValidationRule Validating="EventValidationRule_MultQTDDestinadaCliente" ErrorContent="Bovespa.Ordens.Message.ErroMultQTDDestinadaCliente" />
                                        </Controls:SinacorDecimalTextBox.ValidationRules>
                                    </Controls:SinacorDecimalTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <Controls:Column Name="PercentualDistribuicao"  DisplayMemberPath="PercentualDistribuido" StringFormat="n8"  
                                         HorizontalCellAlignment="Right" Title="Bovespa.Ordens.Label.PercentualDistribuicao"
                                         AllowInsert="True"  AllowUpdate="True"
                                         
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Name="txtPorcentualDistribuicao1" 
                                                                    Value="{Binding PercentualDistribuido}" 
                                                                    Integers="12" Decimals="8" IsRequired="True" >
                                        <Controls:SinacorDecimalTextBox.ValidationRules>
                                            <Validation:EventValidationRule Validating="EventValidationRule_txtPorcentualDistribuicao" ErrorContent="Bovespa.Ordens.Message.ErroTotalPorcentagem1" />
                                            <Validation:EventValidationRule Validating="EventValidationRule_txtPorcentualDistribuicaoValor" ErrorContent="Bovespa.Ordens.Message.ErroPreenchimentoPercentualDistribuicao" />
                                            <Validation:EventValidationRule Validating="EventValidationRule_txtPorcentualDistribuicaoMultiploQtd" ErrorContent="Bovespa.Ordens.Message.ErroPreenchimentoPercentualDistribuicaoMultiploQtd" />
                                            <Validation:EventValidationRule Validating="EventValidationRule_txtPorcentualMaiorZero" ErrorContent="ContaCorrente.Parametro.ExceptionMessage.PorcentagemMaiorZero" />
                                        </Controls:SinacorDecimalTextBox.ValidationRules>
                                    </Controls:SinacorDecimalTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>
                        <Controls:Column Name="TipoLiquidacao" DisplayMemberPath="TipoLiquidacao" 
                                         Title="Bovespa.Ordens.Label.TipoLiquidacao1" 
                                         AllowInsert="True"  AllowUpdate="True"
                                          
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorTextBox Name="txtTipoLiquidacao"  
                                                             Keyboard.PreviewKeyUp="txtTipoLiquidacao_PreviewKeyUp" 
                                                             Text="{Binding TipoLiquidacao}"
                                                             LostFocus="txtTipoLiquidacao_LostFocus" 
                                                             
                                                             >
                                        <Controls:SinacorTextBox.ValidationRules>

                                            <Validation:EventValidationRule Validating="EventValidationRule_TipoLiquidacao"  ErrorContent="Bovespa.Ordens.Message.ErroTipoLiquidacaoInvalida" />
                                        </Controls:SinacorTextBox.ValidationRules>
                                    </Controls:SinacorTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>


                        </Controls:Column>
                        <Controls:Column Name="Carteira" DisplayMemberPath="CodigoCarteira" 
                                         Title="Bovespa.Ordens.Label.CodigoCarteira"
                                         AllowInsert="True"   AllowUpdate="True"
                                         IsRequired="True"   
                                         HorizontalCellAlignment="Right"  
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorInt32TextBox Value="{Binding CodigoCarteira }" Name="txtCarteira" 
                                                                  Integers="3" IsRequired="True" IsFormated="True" >
                                        <Controls:SinacorInt32TextBox.ValidationRules>
                                            <Validation:EventValidationRule Validating="ValorValidationRule_Carteira" ErrorContent="Bovespa.Ordens.Message.ErroCodigoCarteira"  />
                                        </Controls:SinacorInt32TextBox.ValidationRules>
                                    </Controls:SinacorInt32TextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>

                        </Controls:Column>
                        <Controls:Column Name="UsuarioInstitucional" DisplayMemberPath="CodigoAgenteCustodia"  
                                         Title="Bovespa.Ordens.Label.UsuarioInstitucional"
                                         AllowInsert="True"    AllowUpdate="True"
                                         HorizontalCellAlignment="Right"  
                                         
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}"
                                         >
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorInt32TextBox Name="txtUsuarioInstitucional" 
                                                                  Value="{Binding CodigoAgenteCustodia}"
                                                                  Integers="5" IsFormated="False" IsEnabled="False" >

                                        <Controls:SinacorInt32TextBox.ValidationRules>
                                            <Validation:EventValidationRule Validating="UsuarioInstitucional_Validating" ErrorContent="Bovespa.Ordens.Message.UsuarioInstitucional" />
                                        </Controls:SinacorInt32TextBox.ValidationRules>


                                    </Controls:SinacorInt32TextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>
                        <Controls:Column Name="ClienteInstitucional" DisplayMemberPath="CodigoClienteCustodia"  
                                         Title="Bovespa.Ordens.Label.CodigoClienteCustodia" AllowInsert="True"  
                                         HorizontalCellAlignment="Right"    AllowUpdate="True"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorInt32TextBox Value="{Binding CodigoClienteCustodia }" Integers="7" Name="txtClienteInstitucional"  IsEnabled="False" IsFormated="False" >
                                        <Controls:SinacorInt32TextBox.ValidationRules >
                                            <Validation:EventValidationRule Validating="EventValidation_ClienteInstitucional" ErrorContent="Bovespa.Ordens.Message.ErroClienteInstitucional" />
                                        </Controls:SinacorInt32TextBox.ValidationRules>
                                    </Controls:SinacorInt32TextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>
                        <Controls:Column Name="DigitoVerificadorClienteInstitucional" DisplayMemberPath="DigitoClienteCustodiaDigitacao"
                                         Title="Bovespa.Ordens.Label.DigitoVerificadorClienteInstitucional"
                                         AllowInsert="True"  AllowUpdate="True"
                                         HorizontalCellAlignment="Right"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorInt32TextBox Name="txtDigitoVerificadorClienteInst"  
                                                                  Value="{Binding DigitoClienteCustodiaDigitacao}"
                                                                  Integers="1" IsFormated="True" IsEnabled="False" >
                                        <Controls:SinacorInt32TextBox.ValidationRules>
                                            <Validation:EventValidationRule Validating="EventValidationRule_DigitoVerificadorClienteInst" />
                                        </Controls:SinacorInt32TextBox.ValidationRules>
                                    </Controls:SinacorInt32TextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>

                        </Controls:Column>
                        <Controls:Column Name="ReducaoAcrecimoTotal" DisplayMemberPath="PercentualAcrescimo" Title="Bovespa.Ordens.Label.ReducaoAcrescimoTotal" 
                                         AllowInsert="True" StringFormat="n4"    AllowUpdate="True"
                                         HorizontalCellAlignment="Right"   
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}" >

                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Value="{Binding PercentualAcrescimo}" 
                                                                    Integers="4" Decimals="8" AcceptsNegative="True" >
                                        <Controls:SinacorDecimalTextBox.ValidationRules >
                                            <Validation:EventValidationRule Validating="EventValidationRule_ReducaoAcrecimoTotalValor" ErrorContent="Bovespa.Ordens.Message.ErroValorReducaoAcrescimoTotal"   />
                                            <Validation:EventValidationRule Validating="EventValidationRule_ReducaoAcrecimoTotalDigiacao" ErrorContent="Bovespa.Ordens.Message.ErroObriReducaoAcrecimoTotal"  />
                                        </Controls:SinacorDecimalTextBox.ValidationRules>
                                    </Controls:SinacorDecimalTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>
                        <Controls:Column Name="Dolar" DisplayMemberPath="ValorDolar" 
                                         Title="Bovespa.Ordens.Label.Dolar" AllowInsert="True"   AllowUpdate="True"
                                         StringFormat="n4"  HorizontalCellAlignment="Right" 
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}">
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorDecimalTextBox Value="{Binding ValorDolar}" Integers="8" Decimals="4" >
                                        <Controls:SinacorDecimalTextBox.ValidationRules >
                                            <Validation:EventValidationRule Validating="EventValidation_Dolar" ErrorContent="Bovespa.Ordens.Message.ErrDolar" />
                                        </Controls:SinacorDecimalTextBox.ValidationRules>
                                    </Controls:SinacorDecimalTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>


                        </Controls:Column>
                        <Controls:Column Name="IndicadorLiquidacaoExternoCliente" DisplayMemberPath="IndicadorNaoLiquidacao" 
                                         Title="Bovespa.Ordens.Label.IndicadorLiquidacaoExternoCliente"   
                                         AllowInsert="True"   AllowUpdate="True"
                                         CellInsertTemplate="{Binding CellUpdateTemplate, RelativeSource={RelativeSource Self}}"
                                         >
                            <Controls:Column.CellUpdateTemplate>
                                <DataTemplate>
                                    <Controls:SinacorTextBox Name="txtIndicadorLiquidacaoExternoCliente"
                                                             Text="{Binding IndicadorNaoLiquidacao }" 
                                                             MaxLength="1" LostFocus="txtIndicadorLiquidacaoExternoCliente_LostFocus" >
                                        <Controls:SinacorTextBox.ValidationRules>
                                            <Validation:EventValidationRule Validating="IndicadorLiquidacaoExternoCliente_Validating"  ErrorContent="Bovespa.Ordens.Message.ErroIndicadorLiquidacaoExternoCliente" />
                                        </Controls:SinacorTextBox.ValidationRules>
                                    </Controls:SinacorTextBox>
                                </DataTemplate>
                            </Controls:Column.CellUpdateTemplate>
                        </Controls:Column>

                        <Controls:Column Name="IndicadorSistemaExterno" DisplayMemberPath="IndicadorSistemaExterno" 
                                         Title="Bovespa.Ordens.Label.IndicadorSistemaExterno"   AllowUpdate="True"
                                         AllowInsert="True" MaxLength="18" />
                    </Controls:SinacorDataGrid.Columns>
                </Controls:SinacorDataGrid>
            </Grid>
        </Controls:SinacorExpander>

        <Controls:SinacorExpander Grid.Row="3" Grid.Column="0"  Header="{DynamicResource Bovespa.Ordens.Label.Sumarizacao}"  x:Name="exp3" Margin="0,4,0,0" IsExpanded="True">
            <Grid>
                <Controls:SinacorGroupBox Header="{DynamicResource Bovespa.Ordens.Label.Quantidade}" Width="224" Height="101" HorizontalAlignment="Left" VerticalAlignment="Top">
                    <Grid>
                        <Controls:SinacorLabel HorizontalAlignment="Left" VerticalAlignment="Top" Width="70" Content="{DynamicResource Bovespa.Ordens.Label.Total}" Margin="0,0,0,0"/>
                        <Controls:SinacorDecimalTextBox x:Name="txtQuantidadeCasada" Margin="74,0,0,0" Width="136" Value="{Binding Path=QuantidadeCasada}" HorizontalAlignment="Left" VerticalAlignment="Top" IsEnabled="False" Integers="16" Decimals="4" IsFormated="True" AcceptsNegative="True"  />
                        <Controls:SinacorLabel HorizontalAlignment="Left" VerticalAlignment="Top" Width="70" Content="{DynamicResource Bovespa.Ordens.Label.Informado}" Margin="0,25,0,0"/>
                        <Controls:SinacorDecimalTextBox x:Name="txtQuantidadeDigitada"   Margin="74,25,0,0" Width="136" Value="{Binding Path=QuantidadeDigitada}" VerticalAlignment="Top" HorizontalAlignment="Left" IsEnabled="False" Integers="16" Decimals="4" IsFormated="True" AcceptsNegative="True" />
                        <Controls:SinacorLabel HorizontalAlignment="Left" VerticalAlignment="Top" Width="70" Content="{DynamicResource Bovespa.Ordens.Label.Saldo}" Margin="0,50,0,0"/>
                        <Controls:SinacorDecimalTextBox x:Name="TxtSaldo"  Margin="74,50,0,0" Width="136" Value="{Binding Path=Saldo}" VerticalAlignment="Top" HorizontalAlignment="Left"  IsEnabled="False" Integers="16" Decimals="4" IsFormated="True" AcceptsNegative="True"  />
                    </Grid>
                </Controls:SinacorGroupBox>
                <Controls:SinacorGroupBox Header="{DynamicResource Bovespa.Ordens.Label.Percentual}" Height="101" Width="224" HorizontalAlignment="Left" Margin="228,0,0,0" VerticalAlignment="Top"  >
                    <Grid>
                        <Controls:SinacorLabel HorizontalAlignment="Left" VerticalAlignment="Top" Width="70" Content="{DynamicResource Bovespa.Ordens.Label.Total}" Margin="0,0,0,0"/>
                        <Controls:SinacorDecimalTextBox x:Name="txtPercentualCasado"  Margin="74,0,0,0" Width="136" Value="{Binding Path=PercentualCasado}" HorizontalAlignment="Left" VerticalAlignment="Top" Integers="8" Decimals="4" IsFormated="True" IsEnabled="False" AcceptsNegative="True"  />
                        <Controls:SinacorLabel HorizontalAlignment="Left" VerticalAlignment="Top" Width="70" Content="{DynamicResource Bovespa.Ordens.Label.Informado}" Margin="0,25,0,0"/>
                        <Controls:SinacorDecimalTextBox x:Name="txtPercentualDigitado"  Margin="74,25,0,0" Width="136" Value="{Binding Path=PercentualDigitado}" VerticalAlignment="Top" HorizontalAlignment="Left" Integers="8" Decimals="4" IsFormated="True" IsEnabled="False" AcceptsNegative="True"  />
                        <Controls:SinacorLabel HorizontalAlignment="Left" VerticalAlignment="Top" Width="70" Content="{DynamicResource Bovespa.Ordens.Label.Saldo}" Margin="0,50,0,0"/>
                        <Controls:SinacorDecimalTextBox x:Name="txtSaldoPercentual" Margin="74,50,0,0" Width="136" Value="{Binding Path=SaldoPercentual}" VerticalAlignment="Top" HorizontalAlignment="Left" Integers="8" Decimals="4" IsFormated="True" IsEnabled="False" AcceptsNegative="True" />
                    </Grid>
                </Controls:SinacorGroupBox>
                <Controls:SinacorGroupBox Width="224" Height="101" Header="{DynamicResource Bovespa.Ordens.Label.AnexV}" HorizontalAlignment="Left" Margin="456,0,0,0" VerticalAlignment="Top">
                    <Grid>
                        <Controls:SinacorLabel HorizontalAlignment="Left" VerticalAlignment="Top" Width="70" Content="{DynamicResource Bovespa.Ordens.Label.Total}" Margin="0,0,0,0"/>
                        <Controls:SinacorLabel HorizontalAlignment="Left" VerticalAlignment="Top" Width="70" Content="{DynamicResource Bovespa.Ordens.Label.Saldo}" Margin="0,50,0,0"/>
                        <Controls:SinacorLabel HorizontalAlignment="Left" VerticalAlignment="Top" Width="70" Content="{DynamicResource Bovespa.Ordens.Label.Informado}" Margin="0,25,0,0"/>
                        <Controls:SinacorDecimalTextBox x:Name="txtQuantidadeDigitadaAnexoV"  Margin="74,25,0,0" Width="136" Value="{Binding Path=QuantidadeDigitadaAnexoV}" HorizontalAlignment="Left" VerticalAlignment="Top" IsEnabled="False" IsFormated="True" Integers="8" Decimals="4" AcceptsNegative="True"  />
                        <Controls:SinacorDecimalTextBox x:Name="txtQuantidadeCasadaAnexoV"  Margin="74,0,0,0" Width="136" Value="{Binding Path=QuantidadeCasadaAnexoV}" HorizontalAlignment="Left" VerticalAlignment="Top" IsEnabled="False" IsFormated="True" Integers="8" Decimals="4" AcceptsNegative="True"/>
                        <Controls:SinacorDecimalTextBox x:Name="txtSaldoAnexoV"   Margin="74,50,0,0" Width="136" Value="{Binding Path=SaldoAnexoV}" VerticalAlignment="Top" HorizontalAlignment="Left" IsEnabled="False" IsFormated="True" Integers="8" Decimals="4" AcceptsNegative="True" />
                    </Grid>
                </Controls:SinacorGroupBox>
                <Controls:SinacorGroupBox Header="{DynamicResource Bovespa.Ordens.Label.AnexoIV}" Width="224" Height="101" HorizontalAlignment="Left" Margin="684,0,0,0" VerticalAlignment="Top">
                    <Grid>
                        <Controls:SinacorDecimalTextBox x:Name="txtQuantidadeCasadaAnexoIV" Margin="74,0,0,0" Width="136" Value="{Binding Path=QuantidadeCasadaAnexoIV}"  HorizontalAlignment="Left" VerticalAlignment="Top" IsEnabled="False" IsFormated="True" Integers="16" Decimals="4" AcceptsNegative="True"   />
                        <Controls:SinacorLabel HorizontalAlignment="Left" VerticalAlignment="Top" Width="70" Content="{DynamicResource Bovespa.Ordens.Label.Total}" Margin="0,0,0,0"/>
                        <Controls:SinacorLabel HorizontalAlignment="Left" VerticalAlignment="Top" Width="70" Content="{DynamicResource Bovespa.Ordens.Label.Informado}" Margin="0,25,0,0"/>
                        <Controls:SinacorDecimalTextBox x:Name="txtQuantidadeDigitadaAnexoIV"  Margin="74,25,0,0" Width="136" Value="{Binding Path=QuantidadeDigitadaAnexoIV}" HorizontalAlignment="Left" VerticalAlignment="Top" IsEnabled="False" IsFormated="True" Integers="16" Decimals="4"  AcceptsNegative="True"  />
                        <Controls:SinacorLabel HorizontalAlignment="Left" VerticalAlignment="Top" Width="70" Content="{DynamicResource Bovespa.Ordens.Label.Saldo}" Margin="0,50,0,0"  />
                        <Controls:SinacorDecimalTextBox x:Name="txtSaldoAnexoIV"  Margin="74,50,0,0" Width="136"  VerticalAlignment="Top" HorizontalAlignment="Left"  Value="{Binding Path=SaldoAnexoIV}" IsEnabled="False" IsFormated="True" Integers="16" Decimals="4"  AcceptsNegative="True" />
                        <!--Value="{Binding Path=SaldoAnexoIV}" IsEnabled="False" IsFormated="True" Integers="16" Decimals="4"  AcceptsNegative="True"-->
                    </Grid>
                </Controls:SinacorGroupBox>



            </Grid>
        </Controls:SinacorExpander>
    </Controls:SinacorExpanderContainer>
</Controls:SinacorWindow>

